﻿using GalaSoft.MvvmLight;
using Microsoft.Practices.ServiceLocation;
using System;

namespace Songhay.Mvvm.Extensions
{

    /// <summary>
    /// Extension methods the base View Model.
    /// </summary>
    public static partial class ViewModelBaseExtensions
    {
        /// <summary>
        /// Gets the service locator.
        /// </summary>
        /// <param name="viewModelBase">The view model base.</param>
        /// <exception cref="System.NullReferenceException">The expected IoC/Service Locator is not here.</exception>
        public static IServiceLocator GetServiceLocator(this ViewModelBase viewModelBase)
        {
            if (ServiceLocator.Current == null) throw new NullReferenceException("The expected IoC/Service Locator is not here.");
            return ServiceLocator.Current;
        }
    }
}
